
#ifndef __TEST_ERROR_H
#define __TEST_ERROR_H

#define FATAL_IF_BLANK(terrcode, tstring, tdescr, ...) \
   do \
   { \
      if (((tstring) == NULL) || (strlen(tstring) == 0)) \
      { \
         errprint(tdescr " cannot be %s string", ## __VA_ARGS__, (tstring) ? "an empty" : "a NULL"); \
         return terrcode; \
      } \
   } while (0)
   
#define FATAL_IF_BLANK_VECTOR(terrcode, tvector, tdescr, ...) \
   do \
   { \
      if (((tvector) == NULL) || ((tvector)->size() == 0)) \
      { \
         errprint("this vector corresponding to " tdescr " cannot be %s", ## __VA_ARGS__, (tvector) ? "empty" : "NULL"); \
         if (tvector) delete(tvector); \
         return terrcode; \
      } \
   } while (0)
   
#define FATAL_IF_NULL(terrcode, tobj, tdescr, ...) \
   do \
   { \
      if ((tobj) == NULL) \
      { \
         errprint(tdescr " cannot be NULL", ## __VA_ARGS__); \
         return terrcode; \
      } \
   } while (0)

#define FATAL_IF_EXPRESSION(terrcode, texpr, tdescr, ...) \
   do \
   { \
      if (texpr) \
      { \
         errprint(tdescr, ## __VA_ARGS__); \
         return terrcode; \
      } \
   } while (0)

#endif
